package com.yxw.live_vod_boot.controller;

import com.yxw.live_vod_boot.dto.*;
import com.yxw.live_vod_boot.service.OnDemandLikeService;
import com.yxw.live_vod_boot.vo.FansListVO;
import com.yxw.live_vod_boot.vo.OnDemandVideoVo;
import com.yxw.live_vod_boot.vo.VodLikeAndCollectVo;
import com.yxw.yxnet_cd_center.common.dto.PageVO;
import com.yxw.yxnet_cd_center.common.helper.ResultHelper;
import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 点播点赞管理
 *
 * @author liuxin
 * @date 2023.11.24
 */
@RestController
@Api(value = "点播点赞管理", tags = "点播点赞管理")
@Slf4j
@RequestMapping("/api/onDemand/like")
public class OnDemandLikeController {

    @Autowired
    private OnDemandLikeService onDemandLikeService;

    @ApiOperation(value = "视频点赞/取消点赞")
    @PostMapping(value = "/doVideoLike")
    public BaseResult doVideoLike(@RequestBody @Validated VideoLikeDTO dto) {
        onDemandLikeService.doVideoLike(dto);
        return BaseResult.doSuccess(null, "操作成功");
    }

    @ApiOperation(value = "查询当前用户是否对当前视频点赞和当前视频总点赞量")
    @PostMapping(value = "/getVideoLikeInfo")
    public BaseResult getVideoLikeInfo(@RequestBody @Validated VideoLikeDTO dto) {
        return onDemandLikeService.getVideoLikeInfo(dto);
    }

    @ApiOperation(value = "点播点赞信息从redis添加到数据库")
    @PostMapping(value = "/addLikeRecord")
    public BaseResult addLikeRecord() {
        onDemandLikeService.addLikeRecord();
        return BaseResult.doSuccess(null, "执行成功");
    }

    /**
     * 展示当前用户点赞视频列表
     */
    @ApiOperation(value = "展示当前用户点赞视频列表")
    @PostMapping(value = "/getVideoLikeListByUserId")
    public BaseResult<PageVO<OnDemandVideoVo>> getVideoLikeListByUserId(@RequestBody @Validated VideoLikeListQueryDTO dto) {
        PageVO<OnDemandVideoVo> list = onDemandLikeService.getVideoLikeListByUserId(dto);
        return ResultHelper.fillWithSuccess(list);
    }

    @ApiOperation(value = "查询店铺视频点赞和收藏列表")
    @PostMapping(value = "/getVodLikeAndCollectList")
    public BaseResult<PageVO<VodLikeAndCollectVo>> getVodLikeAndCollectList(@RequestBody @Validated  VodLikeAndCollectDto dto) {
        PageVO<VodLikeAndCollectVo> list = onDemandLikeService.getVodLikeAndCollectList(dto);
        return ResultHelper.fillWithSuccess(list);
    }
}
